{template 'tpl_header'}
<div class="bg-color">
    <div class="single-row">
        <div class="single-title">
            <div class="single-title_content">
                {$order['name']}
            </div>
        </div>
        <div class="single-info">
            <div class="single-img">
                <img src="{php echo tomedia($order['thumb'])}" alt="">
            </div>
            <div class="single-detail">
                <div class="single-detail_info">
                    <div class="single-detail_info_row">
                        <span class="single-detail_info_row_title">出行日期：</span>{php echo date('Y.m.d',$order['departure_date'])}
                    </div>
                    <div class="single-detail_info_row">
                        <span class="single-detail_info_row_title">具体时间：</span>{$order['sku']['name']}
                    </div>
                    <div class="single-detail_info_row">
                        <span class="single-detail_info_row_title">出游人数：</span>{$tour_str}
                    </div>
                    <div class="single-detail_info_row">
                        <span class="single-detail_info_row_title">订单号：</span>{$order['order_no']}
                    </div>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
{if $order['adult_number'] != 0 }
<div class="body_style_1">
    <div class="weui-panel weui-panel_access">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p>成人旅客</p>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        {loop $order['adult_members'] $index $adult_members}
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">成人{php echo $index+1 }</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input adult_input" type="text" value="{$adult_members}" placeholder="请输入中文姓名"
                       disabled>
            </div>
        </div>
        {/loop}
    </div>
</div>
{/if}
{if $order['child_number'] != 0 }
<div class="body_style_1">
    <div class="weui-panel weui-panel_access">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p>儿童旅客</p>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        {loop $order['child_members'] $index $child_members}
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">儿童{php echo $index+1 }</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input adult_input" type="text" value="{$child_members}" placeholder="请输入中文姓名"
                       disabled>
            </div>
        </div>
        {/loop}
    </div>
</div>
{/if}
{if $order['baby_number'] != 0 }
<div class="body_style_1">
    <div class="weui-panel weui-panel_access">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p>婴儿旅客</p>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        {loop $order['baby_members'] $index $baby_members}
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">婴儿{php echo $index+1 }</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input adult_input" type="text" value="{$baby_members}" placeholder="请输入中文姓名"
                       disabled>
            </div>
        </div>
        {/loop}
    </div>
</div>
{/if}

<div class="body_style_1">
    <div class="weui-panel weui-panel_access">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p>联系人信息</p>
            </div>
            <div class="weui-cell__ft">

            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">中文姓名</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="contact_name" type="text" value="{$order['contact_name']}"
                       placeholder="与证件姓名一致" disabled>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">手机号码</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="contact_mobile" type="number" value="{$order['contact_mobile']}"
                       placeholder="请输入手机号码" disabled>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">邮箱</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="contact_email" type="email" value="{$order['contact_email']}"
                       placeholder="请输入邮箱" disabled>
            </div>
        </div>
    </div>
</div>
<div class="weui-footer">
    <p class="weui-footer__links">
        <a href="javascript:void(0);" class="weui-footer__link open-popup" data-target="#half">查看详细</a>
    </p>
</div>

<a id="half" class='weui-popup__container popup-bottom close-popup'>
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar">
            <div class="toolbar-inner" style="background-color: #11a4c0;">
                <div class="pay-title">
                    <p>费用详细</p>
                </div>
                <div class="pay-price"><span class="pay-price_left">共</span><span class="pay-price_right">￥{$order["total_price"]}</span>
                </div>
            </div>
        </div>
        <div class="modal-content">
            <div class="weui-grids" style="padding: 15px .5rem 30px .5rem">
                {if $order['adult_number'] != 0 }
                <div class="pay-price_content">
                    <div class="pay-price_content_title">
                        成人
                    </div>
                    <div class="pay-price_content_desc">
                        {$order['adult_number']} x {php echo number_format(round($order['adult_price']*$order['exchange_rate']),2)}
                    </div>
                </div>
                <div class="clear"></div>
                {/if}
                {if $order['child_number'] != 0 }
                <div class="pay-price_content">
                    <div class="pay-price_content_title">
                        儿童
                    </div>
                    <div class="pay-price_content_desc">
                        {$order['child_number']} x {php echo number_format(round($order['child_price']*$order['exchange_rate']),2)}
                    </div>
                </div>
                <div class="clear"></div>
                {/if}
                {if $order['baby_number'] != 0 }
                <div class="pay-price_content">
                    <div class="pay-price_content_title">
                        婴儿
                    </div>
                    <div class="pay-price_content_desc">
                        {$order['baby_number']} x {php echo number_format(round($order['baby_price']*$order['exchange_rate']),2)}
                    </div>
                </div>
                <div class="clear"></div>
                {/if}
            </div>
        </div>
    </div>
</a>

<div class="nav-seize-seat"></div>
<div class="nav-price">
    <div class="nav-price_info">
        <span class="nav-price_info_title">总额：</span><span class="nav-price_info_price">￥{$order["total_price"]}</span>
    </div>
    {if $order['status'] != '1'}
    <div class="nav-price_button">
        <a id="del_order" class="weui-btn weui-btn_mini weui-btn weui-btn_mini weui-btn_default"
           style="margin-top: 0">取消</a>
        <a id="payment" class="weui-btn weui-btn_mini weui-btn_primary" style="margin-top: 0">购买</a>
    </div>
    {/if}
    <div class="clear"></div>
</div>
{template 'tpl_footer'}
<script type="text/javascript" src="{$_W['siteroot']}app/resource/js/lib/mui.min.js"></script>
<script type="text/javascript" src="{$_W['siteroot']}app/resource/js/app/util.js"></script>
<script>
    var is_pay_look = false;
    $(function () {
        FastClick.attach(document.body);

        $('#payment').click(function () {
            if (!is_pay_look) {
                //防止重复提交
                is_pay_look = true;
                var data = {
                    'action': 'get_order_detail',
                    'id': '{$id}',
                    'type': '{$type}'
                };
                $.ajax({
                    url: "{php echo $this->createMobileUrl('ajax')}",
                    type: 'post',
                    data: data,
                    dataType: 'json',
                    success: function (res) {
                        if (res.status == 1) {
                            var data = res.data;
                            util.pay({
                                orderFee: data.total_price,
                                payMethod: 'wechat',
                                orderTitle: data.name,
                                orderTid: data.order_no,
                                module: 'vj_bontrip',
                                type: 'insurance',
                                success: function (result) {
                                    $.toast('支付成功');
                                    window.location.href = "{php echo $this->createMobileUrl('me'); }";
                                },
                                fail: function (result) {
                                    $.toast(result.message, "cancel");
                                    is_pay_look = false;
                                },
                                complete: function (result) {
                                }
                            });

                        } else {
                            is_pay_look = false;
                            $.toast(res.msg, "cancel");
                        }

                    },
                    error: function (res) {
                        is_pay_look = false;
                        $.toast('请求失败，请检测网络或联系客服', "cancel");
                    }
                });

            }
        });

        $('#del_order').click(function () {
            $.confirm({
                title: '是否删除？',
                text: '删除之后无法恢复，是否删除？',
                onOK: function () {
                    //点击确认
                    var is_pay_look = false;
                    if (!is_pay_look) {
                        is_pay_look = true;
                        var data = {
                            'action': 'del_order',
                            'id': '{$id}',
                            'type': '{$type}'
                        };
                        $.ajax({
                            url: "{php echo $this->createMobileUrl('ajax')}",
                            type: 'post',
                            data: data,
                            dataType: 'json',
                            success: function (res) {
                                if (res.status == 1) {
                                var url = "{php echo url('entry', array('m' => 'vj_bontrip','do' => 'order','op' => 'list','type' => $type),true);}";
                                    window.location.replace(url);
                                } else {
                                    is_pay_look = false;
                                    $.toast(res.msg, "cancel");
                                }

                            },
                            error: function (res) {
                                is_pay_look = false;
                                $.toast('请求失败，请检测网络或联系客服', "cancel");
                            }
                        });
                    }
                },
                onCancel: function () {
                }
            });
        });
    });
    $(document).on("open", ".weui-popup-modal", function () {
        console.log("open popup");
    }).on("close", ".weui-popup-modal", function () {
        console.log("close popup");
    });

</script>